#pragma once

#include <sys_def.h>

// APB1寄存器第0到7位的定义
typedef struct {
	u8_s TIMER1 : 1;
	u8_s TIMER2 : 1;
	u8_s TIMER3 : 1;
	u8_s TIMER4 : 1;
	u8_s TIMER5 : 1;
	u8_s TIMER6 : 1;
	u8_s : 2;
} rcu_apb1_0_7_s;

_Static_assert(sizeof(rcu_apb1_0_7_s) == 1,
	       "Struct rcu_apb1_0_7_s defined error!");

// APB1型寄存器第8到15位的定义
typedef struct {
	u8_s : 3;
	u8_s WWDGT : 1;
	u8_s : 2;
	u8_s SPI1 : 1;
	u8_s SPI2 : 1;
} rcu_apb1_8_15_s;

_Static_assert(sizeof(rcu_apb1_8_15_s) == 1,
	       "Struct rcu_apb1_8_15_s defined error!");

// APB1型寄存器第0到15位的定义
typedef struct {
	rcu_apb1_0_7_s apb1en_0_7;
	rcu_apb1_8_15_s apb1en_8_15;
} __attribute__((aligned(2))) rcu_apb1_0_15_s;

_Static_assert(sizeof(rcu_apb1_0_15_s) == 2,
	       "Struct rcu_apb1_0_15_s defined error!");

// APB1寄存器第16到23位的定义
typedef struct {
	u8_s : 1;
	u8_s USART1 : 1;
	u8_s USART2 : 1;
	u8_s USART3 : 1;
	u8_s USART4 : 1;
	u8_s I2C0 : 1;
	u8_s I2C1 : 1;
	u8_s : 1;
} rcu_apb1_16_23_s;

_Static_assert(sizeof(rcu_apb1_16_23_s) == 1,
	       "Struct rcu_apb1_16_23_s defined error!");

// APB1型寄存器第24到31位的定义
typedef struct {
	u8_s : 1;
	u8_s CAN0 : 1;
	u8_s CAN1 : 1;
	u8_s BKPI : 1;
	u8_s PMU : 1;
	u8_s DAC : 1;
	u8_s : 2;
} rcu_apb1_24_31_s;

_Static_assert(sizeof(rcu_apb1_24_31_s) == 1,
	       "Struct rcu_apb1_24_31_s defined error!");

// APB1型寄存器第16到31位的定义
typedef struct {
	rcu_apb1_16_23_s apb1en_16_23;
	rcu_apb1_24_31_s apb1en_24_31;
} __attribute__((aligned(2))) rcu_apb1_16_31_s;

_Static_assert(sizeof(rcu_apb1_16_31_s) == 2,
	       "Struct rcu_apb1_16_31_s defined error!");

// APB1型寄存器的定义
typedef struct {
	rcu_apb1_0_7_s apb1en_0_7;
	rcu_apb1_8_15_s apb1en_8_15;
	rcu_apb1_16_23_s apb1en_16_23;
	rcu_apb1_24_31_s apb1en_24_31;
} __attribute__((aligned(4))) rcu_apb1_s;

_Static_assert(sizeof(rcu_apb1_s) == 4, "Struct rcu_apb1_s defined error!");
